<?php
namespace app\common\validate;

/**
 * 镜像验证类
 * @package app\common\validate
 * @author jwj <jwjbjg@gmail.com>
 * @copyright jwj
 */
class Mirror extends Validate
{
    protected $rule = [
        'id'              => ['require'],
        'type'            => ['require', 'max' => 255],
        'name'            => ['require', 'max' => 255],
        'base_url'        => ['max' => 255],
        'secret'          => ['max' => 255],
        'expire'          => ['integer'],
        'remark'          => ['max' => 255],
        'paid'            => ['require', 'integer'],
        'status'          => ['require', 'integer'],
        'storage_discard' => ['require', 'integer'],
        'sort'            => ['require', 'integer', 'between' => '0,999'],
    ];

    protected $field = [
        'id'              => 'ID',
        'type'            => '类型',
        'name'            => '名称',
        'base_url'        => '网址前缀',
        'secret'          => '密钥',
        'expire'          => '有效期',
        'remark'          => '备注',
        'paid'            => '付费',
        'status'          => '状态',
        'storage_discard' => '储存废弃内容',
        'sort'            => '排序',
    ];

    public function sceneAdd()
    {
        return $this->remove('id', true);
    }

    public function sceneEdit()
    {
        return $this;
    }
}